package com.zhl.study.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.zhl.study.base.ResponseFactory;
import com.zhl.study.service.MassageService;
import com.zhl.study.base.Result;
import com.zhl.study.util.Exif;
import com.zhl.study.util.Shift;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;

/**
 * @author 浩殇
 * @create 2022/12/6--20:37--周二
 * MassageServiceImpl
 */
@Service
public class MassageServiceImpl implements MassageService { //extends ServiceImpl<MassageMapper, PhotoMassage>
    @Override
    public Result<JSONObject> analysis(MultipartFile file)  {
        try {
            File f= Shift.multipartFileToFile(file);
            JSONObject jsonObject= Exif.analysis(f);
            Shift.deleteTempFile(f);//清除缓存
            return ResponseFactory.ok(jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseFactory.fail();
        }
    }
}
